package com.ljfresh.customer.result;

import com.ljfresh.customer.exception.ErrorMap;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @author: Lucifer
 * @time: 2020/4/3-15:13
 */
@ApiModel("返回类")
@Data
public class Result {

    @ApiModelProperty("code")
    public Integer code;

    @ApiModelProperty("描述")
    public String message;

    @ApiModelProperty("描述")
    public Object data;

    public Result(){
        this.code=0;
        this.message="请求成功";
    }

    public void setResult(Integer code){
        this.code = code;
        if (code==0){
            this.message="请求成功";
        }else{
            this.message = ErrorMap.map.get(code);
        }
    }

    public Result(Integer code,String message){
        this.code = code;
        this.message = message;
    }

    public Result(Integer code){
        this.code = code;
        this.message = ErrorMap.map.get(code);
    }

    public Result(Integer code,String message,Object data){
        this.code = code;
        this.message = message;
        this.data = data;

    }

    public Result(Integer code,Object data){
        this.code = code;
        this.data = data;

    }
}
